package day7;

import day4.teacher.MathTeacher;
import day4.teacher.PETeacher;
import day4.teacher.Teacher;
import day5.MuiscTeacher;

import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class SaveObjToXML {
    public static void main(String[] args) {
        List<Teacher> list=new ArrayList<>();
        list.add(new MathTeacher("老胡",53));
        list.add(new PETeacher("laoli",43));
        list.add(new MuiscTeacher("老吴",51));
        list.add(new MathTeacher("小张",22));
        //写入xml
        try {
            XMLEncoder xe=new XMLEncoder(new FileOutputStream("teachers.xml"));
            xe.writeObject(list);
            xe.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
